package com.justgame.project.service.system.controller;


import com.justgame.project.cloud.common.constant.Result;
import com.justgame.project.cloud.common.entity.PageRequest;
import com.justgame.project.service.api.dto.SysHomeColumnDTO;
import com.justgame.project.service.system.service.SysHomeColumnService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/sys/home-column")
public class SysHomeColumnController {

    @Resource
    private SysHomeColumnService sysHomeColumnService;

    /**
     * 首页栏目
     *
     * @return
     */
    @GetMapping("/home-cols")
    public Result<?> getList() {
        return Result.OK(sysHomeColumnService.selectIndexList());
    }

    @GetMapping("/list")
    public Result<Object> getList(SysHomeColumnDTO dto, PageRequest pageRequest) {
        return Result.OK(sysHomeColumnService.selectVoList(dto, pageRequest));
    }

    @DeleteMapping("/delete")
    @RequiresRoles("admin")
    public Result<Object> delete(@RequestBody SysHomeColumnDTO dto) {
        return Result.status(sysHomeColumnService.delete(dto));
    }

    @PostMapping("/save")
    @RequiresRoles("admin")
    public Result<Object> save(@RequestBody SysHomeColumnDTO dto) {
        return Result.status(sysHomeColumnService.save(dto));
    }

    @PutMapping("/update")
    @RequiresRoles("admin")
    public Result<Object> update(@RequestBody SysHomeColumnDTO dto) {
        return Result.status(sysHomeColumnService.updateById(dto));
    }


}
